package com.example.intents;

import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

public class MainActivity extends AppCompatActivity {

    private int requestCode = 1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void onClickWebBrowser(View v){
        Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.baidu.com"));
//        startActivity(i);
//        i.addCategory("com.example.intents.Apps");
        i.addCategory("com.example.intents.OtherApps");
        startActivity(Intent.createChooser(i, "Open URL using..."));
    }

    public void onClickMakeCalls(View v){
        Intent i = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:+8618256372364"));
        startActivity(i);
    }

    public void onClickShowMap(View v){
        Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:37.827500,-122.481670"));

        startActivity(i);
    }

    public void onClickLaunchMyBrowser(View v){
        Intent i = new Intent("com.example.intents.BrowserActivity");
        i.setData(Uri.parse("http://www.baidu.com"));
        startActivity(i);
    }
}
